using System.Collections.Generic;
using SDF.Core;
using SDF.Core.Domain.Projects;

namespace SDF.Services.Projects
{
    /// <summary>
    /// Project mapping service interface
    /// </summary>
    public partial interface IProjectMappingService
    {
        /// <summary>
        /// Deletes a project mapping record
        /// </summary>
        /// <param name="projectMapping">Project mapping record</param>
        void DeleteProjectMapping(ProjectMapping projectMapping);

        /// <summary>
        /// Gets a project mapping record
        /// </summary>
        /// <param name="projectMappingId">Project mapping record identifier</param>
        /// <returns>Project mapping record</returns>
        ProjectMapping GetProjectMappingById(int projectMappingId);

        /// <summary>
        /// Gets project mapping records
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="entity">Entity</param>
        /// <returns>Project mapping records</returns>
        IList<ProjectMapping> GetProjectMappings<T>(T entity) where T : BaseEntity, IProjectMappingSupported;

        /// <summary>
        /// Inserts a project mapping record
        /// </summary>
        /// <param name="projectMapping">Project mapping</param>
        void InsertProjectMapping(ProjectMapping projectMapping);

        /// <summary>
        /// Inserts a project mapping record
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="projectId">Project id</param>
        /// <param name="entity">Entity</param>
        void InsertProjectMapping<T>(T entity, int projectId) where T : BaseEntity, IProjectMappingSupported;

        /// <summary>
        /// Updates the project mapping record
        /// </summary>
        /// <param name="projectMapping">Project mapping</param>
        void UpdateProjectMapping(ProjectMapping projectMapping);

        /// <summary>
        /// Find project identifiers with granted access (mapped to the entity)
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="entity">Wntity</param>
        /// <returns>Project identifiers</returns>
        int[] GetProjectsIdsWithAccess<T>(T entity) where T : BaseEntity, IProjectMappingSupported;

        /// <summary>
        /// Authorize whether entity could be accessed in the current project (mapped to this project)
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="entity">Wntity</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize<T>(T entity) where T : BaseEntity, IProjectMappingSupported;

        /// <summary>
        /// Authorize whether entity could be accessed in a project (mapped to this project)
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="entity">Entity</param>
        /// <param name="projectId">Project identifier</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize<T>(T entity, int projectId) where T : BaseEntity, IProjectMappingSupported;
    }
}